<template>
  <div>
    <div class="q-pa-md q-gutter-sm">
      <div>
        <div class="q-gutter-sm">
          <q-btn size="sm" color="primary" @click="selectGoodService" label="Select 'Good service'" />
          <q-btn v-if="selected" size="sm" color="red" @click="unselectNode" label="Unselect node" />
        </div>
      </div>
      <q-tree
        :nodes="treeData"
        v-model:selected="selected"
        default-expand-all
        node-key="label"
        no-selection-unset
        no-connectors
      >
        <template v-slot:default-header="prop">
          <div class="row items-center" style="width:100vw">
            <q-icon :name="prop.node.icon || 'share'" color="orange" class="q-mr-sm" />
            <q-item-section>
              <q-item-label lines="1">{{ prop.node.label }}</q-item-label>
            </q-item-section>
            <div class="text-grey-8 q-gutter-xs">
              <q-btn class="gt-xs" flat dense round icon="delete" @click="doClickTree"/>
              <q-btn class="gt-xs" flat dense round icon="done" />
              <q-btn flat dense round icon="more_vert" />
            </div>
          </div>
        </template>
      </q-tree>
    </div>



    <div class="q-pa-md q-gutter-md">
      <q-list bordered class="rounded-borders" style="">

        <q-item>
          <q-item-section avatar >
            <q-icon name="account_tree" color="black" size="34px" />
          </q-item-section>

          <q-item-section>
            <q-item-label lines="1">
              <span class="text-weight-medium">[quasarframework/quasar]</span>
              <span class="text-grey-8"> - GitHub repository</span>
            </q-item-label>
          </q-item-section>

          <q-item-section side>
            <div class="text-grey-8 q-gutter-xs">
              <q-btn class="gt-xs" size="12px" flat dense round icon="delete" />
              <q-btn class="gt-xs" size="12px" flat dense round icon="done" />
              <q-btn size="12px" flat dense round icon="more_vert" />
            </div>
          </q-item-section>
        </q-item>


        <q-item>
          <q-item-section avatar >
            <q-icon name="account_tree" color="black" size="34px" />
          </q-item-section>

          <q-item-section >
            <q-item-label lines="1">
              <span class="text-weight-medium">[quasarframework/quasar]</span>
              <span class="text-grey-8"> - GitHub repository</span>
            </q-item-label>
          </q-item-section>

          <q-item-section side>
            <div class="text-grey-8 q-gutter-xs">
              <q-btn class="gt-xs" size="12px" flat dense round icon="delete" />
              <q-btn class="gt-xs" size="12px" flat dense round icon="done" />
              <q-btn size="12px" flat dense round icon="more_vert" />
            </div>
          </q-item-section>
        </q-item>
      </q-list>
    </div>





    <div class="q-pa-md" style="">
      <q-list bordered class="rounded-borders">

        <q-item v-ripple clickable active-class="text-purple">
          <q-item-section avatar>
            <q-icon name="home" />
          </q-item-section>
          <q-item-section>
            <q-item-label>首页</q-item-label>
          </q-item-section>
        </q-item>
        
        <q-expansion-item
          expand-icon-toggle
          expand-separator
          header-class="text-purple"
          icon="folder"
          label="Account settings"
          caption="John Doe"
        >
          <template v-slot:header>
            <q-item-section avatar>
              <q-icon name="folder"/>
            </q-item-section>
            <q-item-section >
              <q-btn flat label="我的空间" padding="none" align="left" style="width: 55vw;"/>
            </q-item-section>

            <q-item-section side>
              <div class="text-grey-8 q-gutter-xs">
                <q-btn flat dense round icon="more_vert" />
              </div>
            </q-item-section>
          </template>

          <q-card>
            <q-card-section>
              <q-tree
                :nodes="treeData"
                v-model:selected="selected"
                :default-expand-all="false"
                node-key="label"
                no-selection-unset
                no-connectors
              >
                <template v-slot:default-header="prop">
                  <div class="row items-center" style="width:100vw">
                    <q-icon :name="prop.node.icon || 'share'" color="orange" class="q-mr-sm" />
                    <q-item-section>
                      <q-item-label lines="1">{{ prop.node.label }}</q-item-label>
                    </q-item-section>
                    <div class="text-grey-8 q-gutter-xs">
                      <q-btn class="gt-xs" flat dense round icon="delete" @click="doClickTree"/>
                      <q-btn class="gt-xs" flat dense round icon="done" />
                      <q-btn flat dense round icon="more_vert" />
                    </div>
                  </div>
                </template>
              </q-tree>
            </q-card-section>
          </q-card>
        </q-expansion-item>

        <q-expansion-item
          expand-icon-toggle
          expand-separator
          icon="signal_wifi_off"
          label="Wifi settings"
        >
          <template v-slot:header>
            <q-item-section avatar>
              <q-icon name="folder"/>
            </q-item-section>
            <q-item-section >
              <q-btn flat label="共享空间" padding="none" align="left" style="width: 55vw;"/>
            </q-item-section>

            <q-item-section side>
              <div class="text-grey-8 q-gutter-xs">
                <q-btn flat dense round icon="more_vert" />
              </div>
            </q-item-section>
          </template>

          <q-tree
            :nodes="treeData"
            v-model:selected="selected"
            :default-expand-all="false"
            node-key="label"
            no-selection-unset
            no-connectors
          >
            <template v-slot:default-header="prop">
              <div class="row items-center" style="width:100vw">
                <q-icon :name="prop.node.icon || 'share'" color="orange" class="q-mr-sm" />
                <q-item-section>
                  <q-item-label lines="1">{{ prop.node.label }}</q-item-label>
                </q-item-section>
                <div class="text-grey-8 q-gutter-xs">
                  <q-btn class="gt-xs" flat dense round icon="delete" @click="doClickTree"/>
                  <q-btn class="gt-xs" flat dense round icon="done" />
                  <q-btn flat dense round icon="more_vert" />
                </div>
              </div>
            </template>
          </q-tree>
        </q-expansion-item>

        <q-item v-ripple clickable>
          <q-item-section avatar>
            <q-icon name="help" />
          </q-item-section>
          <q-item-section>
            <q-item-label>帮助</q-item-label>
          </q-item-section>
        </q-item>
        
      </q-list>
    </div>





    <div class="q-pa-md">
      <q-table
        title="Treats"
        :rows="rows"
        :columns="columns"
        row-key="name"
        selection="multiple"
        v-model:selected="selectedForTable"
        :filter="filter"
        :grid="true"
        :hide-header="false"
      >
        <template v-slot:top-right>
          <q-input borderless dense debounce="300" v-model="filter" placeholder="Search">
            <template v-slot:append>
              <q-icon name="search" />
            </template>
          </q-input>
        </template>

        <template v-slot:item="props">
          <div
            class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
            :style="props.selected ? 'transform: scale(0.95);' : ''"
          >
            <q-card bordered flat :class="props.selected ? ($q.dark.isActive ? 'bg-grey-9' : 'bg-grey-2') : ''">
              <q-card-section>
                <q-checkbox dense v-model="props.selected" :label="props.row.name" />
              </q-card-section>
              <q-separator />
              <q-list dense>
                <q-item v-for="col in props.cols.filter(col => col.name !== 'desc')" :key="col.name">
                  <q-item-section>
                    <q-item-label>{{ col.label }}</q-item-label>
                  </q-item-section>
                  <q-item-section side>
                    <q-item-label caption>{{ col.value }}</q-item-label>
                  </q-item-section>
                </q-item>
              </q-list>
            </q-card>
          </div>
        </template>

      </q-table>
    </div>


    <div class="q-pa-md">
      <div class="q-gutter-y-md column" style="max-width: 300px">
        <q-toggle v-model="dense" label="Dense QInput" />

        <q-input filled v-model="text" :dense="dense" />

        <q-input filled v-model="text" label="Label (stacked)" stack-label :dense="dense" />

        <q-input filled v-model="text" label="Label" :dense="dense" />

        <q-input filled v-model="ph" label="Label" placeholder="Placeholder" hint="With placeholder" :dense="dense" />

        <q-input filled v-model="ph" placeholder="Placeholder" hint="With placeholder" :dense="dense" />

        <q-input filled square v-model="text" hint="With perfect square borders" :dense="dense" />

        <q-input filled v-model="text" :dense="dense">
          <template v-slot:prepend>
            <q-icon name="event" />
          </template>
        </q-input>

        <q-input filled v-model="text" :dense="dense">
          <template v-slot:append>
            <q-avatar>
              <img src="https://cdn.quasar.dev/logo-v2/svg/logo.svg">
            </q-avatar>
          </template>
        </q-input>

        <q-input filled bottom-slots v-model="text" label="Label" counter :dense="dense">
          <template v-slot:prepend>
            <q-icon name="place" />
          </template>
          <template v-slot:append>
            <q-icon name="close" @click="text = ''" class="cursor-pointer" />
          </template>

          <template v-slot:hint>
            Field hint
          </template>
        </q-input>

        <q-input filled bottom-slots v-model="text" label="Label" counter maxlength="12" :dense="dense">
          <template v-slot:before>
            <q-icon name="flight_takeoff" />
          </template>

          <template v-slot:append>
            <q-icon v-if="text !== ''" name="close" @click="text = ''" class="cursor-pointer" />
            <q-icon name="search" />
          </template>

          <template v-slot:hint>
            Field hint
          </template>
        </q-input>

        <q-input filled bottom-slots v-model="text" label="Label" counter maxlength="12" :dense="dense">
          <template v-slot:before>
            <q-avatar>
              <img src="https://cdn.quasar.dev/img/avatar5.jpg">
            </q-avatar>
          </template>

          <template v-slot:append>
            <q-icon v-if="text !== ''" name="close" @click="text = ''" class="cursor-pointer" />
            <q-icon name="schedule" />
          </template>

          <template v-slot:hint>
            Field hint
          </template>

          <template v-slot:after>
            <q-btn round dense flat icon="send" />
          </template>
        </q-input>

        <q-input filled bottom-slots v-model="text" label="Label" counter maxlength="12" :dense="dense">
          <template v-slot:before>
            <q-icon name="event" />
          </template>

          <template v-slot:hint>
            Field hint
          </template>

          <template v-slot:append>
            <q-btn round dense flat icon="add" />
          </template>
        </q-input>

        <q-input filled v-model="text" hint="Disable" :dense="dense" disable />

        <q-input filled v-model="text" hint="Readonly" :dense="dense" readonly />

        <q-input filled v-model="text" hint="Disable and readonly" :dense="dense" disable readonly />
      </div>
    </div>


    <div class="q-pa-md">
      <div class="q-pb-lg">
        <q-toggle v-model="dense" label="Dense QSelect" />
        <q-toggle v-model="denseOpts" label="Dense options" />
      </div>

      <div class="q-gutter-md" style="max-width: 300px">
        <q-select filled v-model="model" :options="options" label="Label (stacked)" stack-label :dense="dense" :options-dense="denseOpts" />

        <q-select outlined v-model="model" :options="options" :dense="dense" :options-dense="denseOpts">
          <template v-slot:prepend>
            <q-icon name="event" />
          </template>
        </q-select>

        <q-select standout v-model="model" :options="options" :dense="dense" :options-dense="denseOpts">
          <template v-slot:append>
            <q-avatar>
              <img src="https://cdn.quasar.dev/logo-v2/svg/logo.svg">
            </q-avatar>
          </template>
        </q-select>

        <q-select filled bottom-slots v-model="model" :options="options" label="Label" counter :dense="dense" :options-dense="denseOpts">
          <template v-slot:prepend>
            <q-icon name="place" @click.stop.prevent />
          </template>
          <template v-slot:append>
            <q-icon name="close" @click.stop.prevent="model = ''" class="cursor-pointer" />
          </template>

          <template v-slot:hint>
            Field hint
          </template>
        </q-select>

        <q-select rounded outlined bottom-slots v-model="model" :options="options" label="Label" counter maxlength="12" :dense="dense" :options-dense="denseOpts">
          <template v-slot:before>
            <q-icon name="flight_takeoff" />
          </template>

          <template v-slot:append>
            <q-icon v-if="model !== ''" name="close" @click.stop.prevent="model = ''" class="cursor-pointer" />
            <q-icon name="search" @click.stop.prevent />
          </template>

          <template v-slot:hint>
            Field hint
          </template>
        </q-select>

        <q-select filled bottom-slots v-model="model" :options="options" label="Label" counter maxlength="12" :dense="dense" :options-dense="denseOpts">
          <template v-slot:before>
            <q-avatar>
              <img src="https://cdn.quasar.dev/img/avatar5.jpg">
            </q-avatar>
          </template>

          <template v-slot:append>
            <q-icon v-if="model !== ''" name="close" @click.stop.prevent="model = ''" class="cursor-pointer" />
            <q-icon name="schedule" @click.stop.prevent />
          </template>

          <template v-slot:hint>
            Field hint
          </template>

          <template v-slot:after>
            <q-btn round dense flat icon="send" />
          </template>
        </q-select>

        <q-select filled bottom-slots v-model="model" :options="options" label="Label" counter maxlength="12" :dense="dense" :options-dense="denseOpts">
          <template v-slot:before>
            <q-icon name="event" />
          </template>

          <template v-slot:hint>
            Field hint
          </template>

          <template v-slot:append>
            <q-btn round dense flat icon="add" @click.stop.prevent />
          </template>
        </q-select>
      </div>
    </div>



    <div class="q-pa-md">
      <div class="q-gutter-md">
        <q-btn color="accent" label="Fit Menu" style="width: 280px;">

          <q-menu fit>
            <q-list style="min-width: 100px">
              <q-item clickable>
                <q-item-section>New tab</q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>New incognito tab</q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>Recent tabs</q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>History</q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>Downloads</q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>Settings</q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>Help &amp; Feedback</q-item-section>
              </q-item>
            </q-list>
          </q-menu>
        </q-btn>

        <q-btn color="brown" label="Max Height Menu">
          <q-menu max-height="130px">
            <q-list style="min-width: 100px">
              <q-item clickable>
                <q-item-section>New tab</q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>New incognito tab</q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>Recent tabs</q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>History</q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>Downloads</q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>Settings</q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>Help &amp; Feedback</q-item-section>
              </q-item>
            </q-list>
          </q-menu>
        </q-btn>

        <q-btn color="indigo" label="Max Width Menu">
          <q-menu max-width="80px">
            <q-list style="min-width: 100px">
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">New tab</q-item-label>
                </q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">New incognito tab</q-item-label>
                </q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">Recent tabs</q-item-label>
                </q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">History</q-item-label>
                </q-item-section>
              </q-item>
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">Downloads</q-item-label>
                </q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">Settings</q-item-label>
                </q-item-section>
              </q-item>
              <q-separator />
              <q-item clickable>
                <q-item-section>
                  <q-item-label lines="1">Help & Feedback</q-item-label>
                </q-item-section>
              </q-item>
            </q-list>
          </q-menu>
        </q-btn>

      </div>
    </div>




    <div class="q-pa-md q-gutter-sm">
      <q-btn label="Basic scroll" color="primary" @click="basic = true" />
      <q-btn label="Fixed size" color="primary" @click="fixed = true" />

      <q-dialog v-model="basic" transition-show="rotate" transition-hide="rotate">
        <q-card>
          <q-card-section>
            <div class="text-h6">Terms of Agreement</div>
          </q-card-section>

          <q-card-section class="q-pt-none">
            <p v-for="n in 15" :key="n">Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum repellendus sit voluptate voluptas eveniet porro. Rerum blanditiis perferendis totam, ea at omnis vel numquam exercitationem aut, natus minima, porro labore.</p>
          </q-card-section>

          <q-card-actions align="right">
            <q-btn flat label="Decline" color="primary" v-close-popup />
            <q-btn flat label="Accept" color="primary" v-close-popup />
          </q-card-actions>
        </q-card>
      </q-dialog>

      <q-dialog v-model="fixed">
        <q-card>
          <q-card-section>
            <div class="text-h6">Terms of Agreement</div>
          </q-card-section>

          <q-separator />

          <q-card-section style="max-height: 50vh" class="scroll">
            <p v-for="n in 15" :key="n">Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum repellendus sit voluptate voluptas eveniet porro. Rerum blanditiis perferendis totam, ea at omnis vel numquam exercitationem aut, natus minima, porro labore.</p>
          </q-card-section>

          <q-separator />

          <q-card-actions align="right">
            <q-btn flat label="Decline" color="primary" v-close-popup />
            <q-btn flat label="Accept" color="primary" v-close-popup />
          </q-card-actions>
        </q-card>
      </q-dialog>
    </div>




    <div class="q-pa-md">
      <div class="q-gutter-y-md" style="max-width: 600px">
        <q-tabs
          v-model="tab"
          class="text-teal"
        >
          <q-tab name="mails" icon="mail" label="Mails" />
          <q-tab name="alarms" icon="alarm" label="Alarms" />
          <q-tab name="movies" icon="movie" label="Movies" />
        </q-tabs>

        <q-tabs
          v-model="tab"
          inline-label
          class="bg-purple text-white shadow-2"
        >
          <q-tab name="mails" icon="mail" label="Mails" />
          <q-tab name="alarms" icon="alarm" label="Alarms" />
          <q-tab name="movies" icon="movie" label="Movies" />
        </q-tabs>

        <q-tabs
          v-model="tab"
          no-caps
          class="bg-orange text-white shadow-2"
        >
          <q-tab name="mails" label="Mails" />
          <q-tab name="alarms" label="Alarms" />
          <q-tab name="movies" label="Movies" />
        </q-tabs>

        <q-tabs
          v-model="tab"
          class="bg-teal text-yellow shadow-2"
        >
          <q-tab name="mails" icon="mail" />
          <q-tab name="alarms" icon="alarm" />
          <q-tab name="movies" icon="movie" />
        </q-tabs>

        <q-tabs
          v-model="tab"
          inline-label
          class="bg-primary text-white shadow-2"
        >
          <q-tab name="mails" icon="mail" label="Mails" />
          <q-tab name="alarms" icon="alarm" label="Alarms" />
          <q-tab name="movies" icon="movie" label="Movies" />
          <q-tab name="photos" icon="photo" label="Photos" />
          <q-tab name="videos" icon="slow_motion_video" label="Videos" />
          <q-tab name="addressbook" icon="people" label="Address Book" />
        </q-tabs>
      </div>
    </div>

  </div>
</template>

<script>
import { ref } from 'vue'

const columns = [
  { name: 'calories', align: 'center', label: 'Calories', field: 'calories', sortable: true },
  { name: 'fat', label: 'Fat (g)', field: 'fat', sortable: true },
  { name: 'carbs', label: 'Carbs (g)', field: 'carbs' },
  { name: 'protein', label: 'Protein (g)', field: 'protein' },
  { name: 'sodium', label: 'Sodium (mg)', field: 'sodium' },
  { name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) },
  { name: 'iron', label: 'Iron (%)', field: 'iron', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) }
]

const rows = [
  {
    name: 'Frozen Yogurt',
    calories: 159,
    fat: 6.0,
    carbs: 24,
    protein: 4.0,
    sodium: 87,
    calcium: '14%',
    iron: '1%'
  },
  {
    name: 'Ice cream',
    calories: 237,
    fat: 9.0,
    carbs: 37,
    protein: 4.3,
    sodium: 129,
    calcium: '8%',
    iron: '1%'
  },
  {
    name: 'Eclair',
    calories: 262,
    fat: 16.0,
    carbs: 23,
    protein: 6.0,
    sodium: 337,
    calcium: '6%',
    iron: '7%'
  },
  {
    name: 'Cupcake',
    calories: 305,
    fat: 3.7,
    carbs: 67,
    protein: 4.3,
    sodium: 413,
    calcium: '3%',
    iron: '8%'
  },
  {
    name: 'Gingerbread',
    calories: 356,
    fat: 16.0,
    carbs: 49,
    protein: 3.9,
    sodium: 327,
    calcium: '7%',
    iron: '16%'
  },
  {
    name: 'Jelly bean',
    calories: 375,
    fat: 0.0,
    carbs: 94,
    protein: 0.0,
    sodium: 50,
    calcium: '0%',
    iron: '0%'
  },
  {
    name: 'Lollipop',
    calories: 392,
    fat: 0.2,
    carbs: 98,
    protein: 0,
    sodium: 38,
    calcium: '0%',
    iron: '2%'
  },
  {
    name: 'Honeycomb',
    calories: 408,
    fat: 3.2,
    carbs: 87,
    protein: 6.5,
    sodium: 562,
    calcium: '0%',
    iron: '45%'
  },
  {
    name: 'Donut',
    calories: 452,
    fat: 25.0,
    carbs: 51,
    protein: 4.9,
    sodium: 326,
    calcium: '2%',
    iron: '22%'
  },
  {
    name: 'KitKat',
    calories: 518,
    fat: 26.0,
    carbs: 65,
    protein: 7,
    sodium: 54,
    calcium: '12%',
    iron: '6%'
  }
]

export default {
  setup () {
    const selected = ref(null)
    const selectedForTable = ref([])

    return {
      selected,
      filter: ref(''),
      selectedForTable,
      columns,
      rows,

      text: ref(''),
      ph: ref(''),
      dense: ref(false),

      model: ref(null),
      options: [
        'Google', 'Facebook', 'Twitter', 'Apple', 'Oracle'
      ],
      denseOpts: ref(false),

      basic: ref(false),
      fixed: ref(false),

      tab: ref('mails'),

      doClickTree(e) {
        console.log('good', e)
        e.preventDefault()
      },

      selectGoodService () {
        if (selected.value !== 'Good service') {
          selected.value = 'Good service'
        }
      },

      unselectNode () {
        selected.value = null
      },

      treeData: [
        {
          label: 'Good food',
          icon: 'restaurant_menu',
          children: [
            { label: 'Quality ingredients' },
            { label: 'Good recipe' }
          ]
        },
        {
          label: 'Good service',
          icon: 'room_service',
          children: [
            {
              label: 'Prompt attention',
              children: [
                { label: 'child1' },
                { label: 'child2' }
              ]
            },
            { label: 'Professional waiter' }
          ]
        },
        {
          label: 'Pleasant surroundings',
          icon: 'photo',
          children: [
            {
              label: 'Happy atmosphere'
            },
            {
              label: 'Good table presentation'
            },
            {
              label: 'Pleasing decor'
            }
          ]
        }
      ]
    }
  }
}


</script>

<style lang="sass">
.grid-style-transition
  transition: transform .28s, background-color .28s
</style>
